<!-- 继承公共视图文件 -->
<extend name="./Application/Admin/View/layout.html" />
 <!-- 可变内容区域 -->
 <block name="mid">

	<div class="row">
	    <div class="col-md-6">
	        <div class="panel panel-default">
	            <div class="panel-heading">
	                <h2><i class="fa fa-indent red"></i><strong>添加广告</strong></h2>
	            </div>
				<form action="" method="post" id="signupForm" enctype="multipart/form-data" class="form-horizontal">
				    <div class="panel-body">

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="select">广告位置</label>
                            <div class="col-md-9">
                                <select id="select" name="point_id" class="form-control" size="1">
                                    <option value="0">请选择广告位置</option>
                                        <foreach name="list" item="v">
                                          <option value="{$v.id}">{$v.name}</option>
                                        </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
		                    <label class="col-md-3 control-label" for="text-input">广告名称</label>
		                    <div class="col-md-9">
		                        <input type="text" id="b_name" name="b_name" class="form-control" placeholder="请输入账号">
		                        <span class="help-block error"></span>
		                    </div>
		                </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="password-input">链接</label>
                            <div class="col-md-9">
                                <input type="text" id="http" name="http" class="form-control" placeholder="请输入确认密码">
                            </div>
                        </div>
		                <div class="form-group">
		                    <label class="col-md-3 control-label" for="password-input">排序</label>
		                    <div class="col-md-9">
		                        <input type="text" id="sort" name="sort" class="form-control" placeholder="请输入确认密码">
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-3 control-label">显示</label>
		                    <div class="col-md-9">
		                        <label class="radio-inline" for="inline-radio1">
		                        	<input type="radio" id="status" name="status" value="1"> 是
		                        </label>
		                        <label class="radio-inline" for="inline-radio2">
		                        	<input type="radio" id="status" name="status" value="0"> 否
		                        </label>
		                    </div>
		                    <span class="help-block error"></span>
		                </div>

		                <div class="form-group">
		                    <label class="col-md-3 control-label" for="file-input">广告图片上传</label>
		                    <div class="col-md-9">
		                        <input type="file" id="img" name="img">
		                    </div>
		                </div>

						<br>
				</div>
				<div class="panel-footer">
                    <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i> 提交</button>
                    <button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i> 重置</button>
                </div>
		      </form>
	        </div>
	    </div>

	</div><!--/.row-->

</block>
<block name="js">

    <script type="text/javascript" src="__ADMIN__assets/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="__ADMIN__assets/js/jquery.validate.min.js"></script>
	<script type="text/javascript">
		$(function(){

		  // 在键盘按下并释放及提交后验证提交表单
		  $("#signupForm").validate({

		  	// debug:true,  //开发的时候组织表单提交

		  	// 验证规则
		    rules: {
              /*'username':'required', //必填验证(单个规则写法)*/

              // 多个验证写法
              'username':{
              	 required:true,
              	 maxlength:10,
                 minlength:4,
              },
              'password':{
              	 required:true,
              	 equalTo:"#cpassword",  //密码输入框的值必须和确认密码输入框的值一样
              },
              'sex':{
              	 required:true,
              }
		    },

		    // 错误信息提示
		    messages: {
		      username: {
		        required: "请输入用户名",
		        maxlength: "用户名长度必需在4~10位数之间",
		        minlength: "用户名长度必需在4~10位数之间",
		      },
		      password: {
		        required: "请输入密码",
		        equalTo: "两次密码不一致",
		      },
		      sex: {
		        required: "请选择性别",
		      },
		    },

		    errorElement:'span',



		  })

		    // 验证码倒计时
	        var s = 5;
	        var time = 0;
	        $('#code').click(function(){
	        	var code = $(this);
            	var tel = $('#tel').val();//获取手机号码
                $.ajax({
                	url:"{:U('Admin/Ajax/send_sms')}",
                	data:{
                		'tel':tel,
                	},
                	type:'post',
                	success:function(suc){

                        if(suc>0){
                        	alert('验证码发送成功');
                        }else{
                        	alert('验证码发送失败');
                        }
                	}
                })
                // 倒计时
	        	time = setInterval(function(){
                    if(s>0){
                    	var txt = s+'后重新获取验证码';
                    	code.val(txt);
                    	code.attr('disabled','disabled');
                        s--;
                    }else{
                    	s = 5;
                    	var txt ='获取验证码';
                    	code.val(txt);
                    	code.attr('disabled',false);
                    	clearInterval(time);
                    }
	        	},1000)
	        })
		})
	</script>
</block>